package java3.io;

public class B21Util
{
  private static int[][] posiciones = new int[2][64];
  public static final int pawn = 1;
  public static final int knight = 2;
  public static final int bishop = 3;
  public static final int rook = 4;
  public static final int queen = 5;
  public static final int king = 6;
  public static final int white = 0;
  public static final int black = 1;
  private static boolean enroquecorto;
  private static boolean enroquelargo;
  private static boolean enroquecortoRival;
  private static boolean enroquelargoRival;

  public static void setPosiciones(int[][] paramArrayOfInt)
  {
    posiciones = paramArrayOfInt;
  }

  public static int[][] obtenerPosicion(int paramInt)
  {
    int[][] localObject = new int[2][64];

    switch (paramInt) {
    case -1:
      localObject = posiciones;
      break;
    case 0:
      localObject = new int[][] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 } };

      break;
    case 1:
      localObject = new int[][] { { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } };

      break;
    case 2:
      localObject = new int[][] { { 4, 2, 3, 5, 6, 3, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 2, 3, 5, 6, 3, 2, 4 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } };

      break;
    default:
      localObject = (int[][])null;
    }

    return localObject;
  }

  public static void ingresarJugada(int paramInt1, int paramInt2, int paramInt3)
  {
    int i = 0;
    int j = posiciones[0][paramInt1];

    if (j == 1)
    {
      switch (paramInt3) {
      case 2:
        i = 5;

        break;
      case 3:
        i = 4;

        break;
      case 4:
        i = 3;

        break;
      case 5:
        i = 2;
      }

      if (paramInt2 > paramInt1) {
        if ((paramInt1 >= 32) && (paramInt1 <= 39) && 
          (paramInt1 + 8 != paramInt2) && 
          (posiciones[0][paramInt2] == 0)) {
          posiciones[0][(paramInt2 - 8)] = 0;
          posiciones[1][(paramInt2 - 8)] = 2;
        }

      }
      else if ((paramInt1 >= 24) && (paramInt1 <= 31) && 
        (paramInt1 - 8 != paramInt2) && 
        (posiciones[0][paramInt2] == 0)) {
        posiciones[0][(paramInt2 + 8)] = 0;
        posiciones[1][(paramInt2 + 8)] = 2;
      }

    }
    else if ((j == 6) && (
      (paramInt1 == 4) || (paramInt1 == 60))) {
      switch (paramInt2) {
      case 2:
        posiciones[0][3] = 4;
        posiciones[1][3] = 0;

        posiciones[0][0] = 0;
        posiciones[1][0] = 2;
        break;
      case 6:
        posiciones[0][5] = 4;
        posiciones[1][5] = 0;

        posiciones[0][7] = 0;
        posiciones[1][7] = 2;
        break;
      case 58:
        posiciones[0][59] = 4;
        posiciones[1][59] = 1;

        posiciones[0][56] = 0;
        posiciones[1][56] = 2;
        break;
      case 62:
        posiciones[0][61] = 4;
        posiciones[1][61] = 1;

        posiciones[0][63] = 0;
        posiciones[1][63] = 2;
      }

    }

    posiciones[0][paramInt2] = (i != 0 ? i : posiciones[0][paramInt1]);
    posiciones[1][paramInt2] = posiciones[1][paramInt1];

    posiciones[0][paramInt1] = 0;
    posiciones[1][paramInt1] = 2;
  }

  public static String pos1(int paramInt)
  {
    String str = null;

    if (paramInt < 8)
      str = new StringBuilder().append(pos2(paramInt)).append(1).toString();
    else {
      str = new StringBuilder().append(pos2(paramInt % 8)).append(paramInt / 8 + 1).toString();
    }

    return str;
  }

  private static String pos2(int paramInt)
  {
    switch (paramInt) {
    case 0:
      return "a";
    case 1:
      return "b";
    case 2:
      return "c";
    case 3:
      return "d";
    case 4:
      return "e";
    case 5:
      return "f";
    case 6:
      return "g";
    case 7:
      return "h";
    }
    return "x";
  }

  public static String obtenerNotacionFEN(int[][] paramArrayOfInt)
  {
    String str1 = "";
    String str2 = "";

    for (int i = 0; i < 64; i++) {
      int j = paramArrayOfInt[0][i];
      int k = paramArrayOfInt[1][i];

      if ((i + 1) % 8 != 0) {
        str2 = new StringBuilder().append(str2).append(devolverPieza(j, k)).toString();
      } else {
        str1 = new StringBuilder().append(i != 63 ? "/" : "").append(str2).append(devolverPieza(j, k)).append(str1).toString();
        str2 = "";
      }
    }

    return transformarFEN(str1);
  }

  private static String devolverPieza(int paramInt1, int paramInt2)
  {
    String str = "";

    switch (paramInt1) {
    case 1:
      str = paramInt2 == 0 ? "P" : "p";
      break;
    case 3:
      str = paramInt2 == 0 ? "B" : "b";
      break;
    case 2:
      str = paramInt2 == 0 ? "N" : "n";
      break;
    case 4:
      str = paramInt2 == 0 ? "R" : "r";
      break;
    case 5:
      str = paramInt2 == 0 ? "Q" : "q";
      break;
    case 6:
      str = paramInt2 == 0 ? "K" : "k";
      break;
    case 0:
      str = "1";
    }

    return str;
  }

  private static String transformarFEN(String paramString)
  {
    String str = "";

    int i = 0;

    for (int j = 0; j < paramString.length(); j++) {
      char c = paramString.charAt(j);

      if (c == '1') {
        i++;
      }
      else if (i != 0) {
        str = new StringBuilder().append(str).append(String.valueOf(i)).append(String.valueOf(c)).toString();
        i = 0;
      } else {
        str = new StringBuilder().append(str).append(String.valueOf(c)).toString();
      }
    }

    if (i != 0) {
      str = new StringBuilder().append(str).append(String.valueOf(i)).toString();
    }

    return str;
  }

    public static boolean isEnroquecorto() {
        return enroquecorto;
    }

    public static void setEnroquecorto(boolean oo) {
        enroquecorto = oo;
    }

    public static boolean isEnroquelargo() {
        return enroquelargo;
    }

    public static void setEnroquelargo(boolean ooo) {
        enroquelargo = ooo;
    }

    public static boolean isEnroquecortoRival() {
        return enroquecortoRival;
    }

    public static void setEnroquecortoRival(boolean oo) {
        enroquecortoRival = oo;
    }

    public static boolean isEnroquelargoRival() {
        return enroquelargoRival;
    }

    public static void setEnroquelargoRival(boolean ooo) {
        enroquelargoRival = ooo;
    }
}
